############################
##                       _oo0oo_
##                      o8888888o
##                      88" . "88
##                      (| -_- |)
##                      0\  =  /0
##                    ___/`---'\___
##                  .' \\|     |// '.
##                 / \\|||  :  |||// \
##                / _||||| -:- |||||- \
##               |   | \\\  - /// |   |
##               | \_|  ''\---/''  |_/ |
##               \  .-\__  '-'  ___/-. /
##             ___'. .'  /--.--\  `. .'___
##          ."" '<  `.___\_<|>_/___.' >' "".
##         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
##         \  \ `_.   \_ __\ /__ _/   .-` /  /
##     =====`-.____`.___ \_____/___.-`___.-'=====
##                       `=---='
##
##
##     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##
##           佛祖保佑     永不宕机     永无BUG
##
##LastEditors: PartyParrot(__init__)
##Date: 2022-06-12 20:54:16
##LastEditTime: 2022-06-12 20:56:17
##FilePath: EasyPosition.py
##Author: PartyParrot(__init__)
##Description: 
############################

# -*- coding: utf-8 -*-

class Position:
    def __init__(self, index, line_number, column_number, file_name, file_text):
        """\
        index: 索引
        line_number: 行数
        column_number: 列数
        file_name: 文件名
        file_text: 文件代码
        """
        self.index = index
        self.line_number = line_number
        self.column_number = column_number
        self.file_name = file_name
        self.file_text = file_text

    def advance(self, current_char):
        """\
        advance: 预读取
        current_char: 当前字符
        """
        self.index += 1
        self.column_number += 1
        
        if current_char == '\n':
            self.line_number += 1
            self.column_number = 0
        
        return self

    def copy(self):
        return Position(self.index, self.line_number, self.column_number, self.file_name, self.file_text)